
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Rectangle.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Rect)
{
	TEST(should be able to calculate area: 2.4*3=7.2)
	{
		Rectangle rect(2.4,3);
		ASSERT_EQ(7.2, rect.getArea());
	}
	TEST(should be able to calculate perimeter: 2*(2.4+3)=10.8)
	{
		Rectangle rect(2.4,3);
		ASSERT_EQ(10.8, rect.getPerimeter());
	}
	TEST(should be able to set width: 75)
	{
		Rectangle rect(2.4,3);
		ASSERT_TRUE(rect.setWidth(75));
	}
};

FIXTURE(Rect_OutOfRange)
{
	TEST(should be able to identify abnormal rectangle setting: width < 0)
	{
		Rectangle rect(-2,3);
		ASSERT_EQ(INVALID_VALUE_FOR_RECT, rect.getArea());
	}
	TEST(should be able to identify abnormal rectangle setting: width < 0)
	{
		Rectangle rect(-2,3);
		ASSERT_EQ(INVALID_VALUE_FOR_RECT, rect.getPerimeter());
	}

	TEST(should be able to identify abnormal rectangle setting: height < 0)
	{
		Rectangle rect(2,-3);
		ASSERT_EQ(INVALID_VALUE_FOR_RECT, rect.getArea());
	}
	TEST(should be able to identify abnormal rectangle setting: height < 0)
	{
		Rectangle rect(2,-3);
		ASSERT_EQ(INVALID_VALUE_FOR_RECT, rect.getPerimeter());
	}
};
